﻿/*
* Description 版权所有2006@qz http://www.quick35.com
* @author crlnet
* @version 1.1
* @discription:站点通用类,存储一些静态信息;如:数据地址,缩放,初始化;
*/

package com.crlclr.common {
	import com.crlclr.data.*;
	import com.crlclr.utils.*;
	
	import flash.display.*;
	
	public class SiteStatic{
		public static var hasToolBar:Boolean=true;
		public static var prefix:String = undefined;
		
		public static var qqhost:String="http://xalist.photo.qq.com/fcgi-bin/fcg_list_album?uin={0}&output_type=xml";
		public static var qqpics:String="http://xaplist.photo.qq.com/fcgi-bin/fcg_list_photo?uin={0}&albumid={1}&outstyle=xml"

		//配置文件地址;
		public static var qqcode:String ="";
		public static var TimeLine:DisplayObject;
					
		/**
		* 初始化时间轴变量,用于记住这全局的对像.
		* @param	timeLine
		* @param	moviePath
		*/
		public static function init (qqcode:String,prefix:String):void {
			SiteStatic.qqcode=qqcode;
			//QQ上不做相对路径;
			SiteStatic.prefix=prefix;
		}
		
		/**
		 * 取得qq 相册列表地址; 
		 * @param code
		 * @return 
		 * 
		 */	
		public static function get qqcodeAlbumsPath():String{
			var url:String=StringUtil.substitute(qqhost,qqcode);
			if(prefix.length>0){
				url=encode(url);
			}
			return prefix+url;
		}
		
		public static function albumPicturesPath(albumID:String):String{
			var url:String=StringUtil.substitute(qqpics,qqcode,albumID);
			if(prefix.length>0){
				url=encode(url);
			}
			return prefix+url;
		}
		
		
		/**
		 * 取得新路径; 
		 * @param url
		 * @return 
		 * 
		 */		
		public static function getPath(url:String):String{
			if(prefix.length>0){
				url=encode(url);
			}
			return prefix+url;
		}
		
		private static function encode(url:String):String{
			url=url.replace("?","$crl$");
			while(url.indexOf("&")>0){
				url=url.replace("&","@crl@");
			}
			return url;
		}
		
		/**
		* 取得书本的缩放比例;
		* @param	Height
		* @return
		
		public static function bookAvg(height:Number):Number{
			var sh:int=1024;
			var value:Number=Number(sh/height);
			return value;
		}*/
	}
}
